package uk.ac.ebi.bioinvindex.dao.ejb3;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.persistence.EntityManager;

import uk.ac.ebi.bioinvindex.dao.*;
import uk.ac.ebi.bioinvindex.model.impl.term.OntologyEntryImpl;

/**
 * User: Nataliya Sklyar (nsklyar@ebi.ac.uk)
 * Date: Jan 15, 2008
 */
public class DaoFactory {

	private static final Log log = LogFactory.getLog( DaoFactory.class );

	private EntityManager entityManager;

	protected DaoFactory(EntityManager entityManager) {
		this.entityManager = entityManager;
	}

	public static DaoFactory getInstance(EntityManager entityManager) {
		return new DaoFactory(entityManager);
	}

	public StudyDAO getStudyDAO() {
		return new StudyEJB3DAO(entityManager);
	}

	public OntologyEntryDAO<OntologyEntryImpl> getOntologyEntryDAO() {
		return new OntologyEntryEJB3DAO<OntologyEntryImpl>(OntologyEntryImpl.class, entityManager);
	}

	public <T extends OntologyEntryImpl> OntologyEntryDAO<T> getOntologyEntryDAO(Class<T> type) {
		return new OntologyEntryEJB3DAO<T>(type, entityManager);
	}

	public InvestigationDao getInvestigationDao() {
		return new InvestigationEJB3DAO(entityManager);
	}

	public ReferenceSourceDAO getReferenceSourceDAO(){
		return new ReferenceSourceEJB3DAO(entityManager);
	}

	public ContactDao getContactDao() {
		return new ContactEJB3DAO(entityManager);
	}

	public EntityManager getEntityManager() {
		return entityManager;
	}
}
